﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace ChaoDaoOs2
{
    class DllClass
    {
        public delegate void SensorInfo(double NetWeight, double Tare, double Grossweight, int Mode, int DecimalDigit, int UnitChar,
                             int OldAd, int FilterAd, int ZeroAd, int WeightAd, int flag);
        public delegate void IS1Info(string status, string sign, string Weight, string fUnit, int flag);

        [DllImport("SensorDll.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public extern static bool __Open(string CommName, int BaudRate);

        [DllImport("SensorDll.dll")]
        public extern static bool __Close();

        [DllImport("SensorDll.dll")]
        public extern static string __GetWeight();

        [DllImport("SensorDll.dll")]
        public extern static bool __GetWeightEx(ref StringBuilder ret);

        [DllImport("SensorDll.dll")]
        public extern static bool __Weight(string Id);
        [DllImport("SensorDll.dll")]
        public extern static bool __SetUnitValue(UInt16 value, string Id);

        [DllImport("SensorDll.dll")]
        public extern static bool __Zero(string Id);

        [DllImport("SensorDll.dll")]
        public extern static bool __Tare(string Id);

        [DllImport("SensorDll.dll")]
        public extern static void __SetCallBackFunc(string funcId, Delegate funcInfo);

        [DllImport("SensorDll.dll")]
        public extern static bool __ChangeProtocol(UInt16 value);

        [DllImport("SensorDll.dll")]
        public extern static bool __EnumUsbDeviceStr(ref StringBuilder devs);

        [DllImport("SensorDll.dll")]
        public extern static bool __SetCommMode(UInt16 iMode);

        [DllImport("SensorDll.dll")]
        public extern static bool __SetUsbDeviceStr(string sDev);
        [DllImport("SensorDll.dll")]
        public extern static string __udeWeight();

    }
}